package com.just.gameapp.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.just.gameapp.entity.Game;
import com.just.gameapp.mapper.GameMapper;
import com.just.gameapp.service.GameService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zyr
 * @date 2024/6/18 下午2:58
 * @Description
 */
@Slf4j
@Service
public class GameServiceImpl extends ServiceImpl<GameMapper, Game> implements GameService {
    @Resource
    private GameMapper gameMapper;

    // 根据输入游戏名模糊查询
    @Override
    public List<Game> searchGame(String gameName) {
        LambdaQueryWrapper<Game> query = new LambdaQueryWrapper<>();
        query.like(Game::getGameName, gameName);
        List<Game> games = gameMapper.selectList(query);
        if (games.isEmpty()) {
            return null;
        }
        return games;
    }
}
